# @Filename:    03-张量的数值计算
# @Author:      王佳伟
# @Time:        2025-03-20 15:02
# @Describe:
import torch

# 1. 张量的数值计算
# data = torch.randint(0, 10, [2, 3])
# print(data)
#
# new_data = data.add(10)
# print(new_data)
#
# data.add_(10)
# print(data)
#
# print(data.sub(100))
# print(data.mul(100))
# print(data.div(100))
# print(data.neg())

# # 2. 张量的点乘运算
# data1 = torch.tensor([[1, 2], [3, 4]])
# data2 = torch.tensor([[5, 6], [7, 8]])
# # 第一种方式
# data = torch.mul(data1, data2)
# print(data)
#
# # 第二种方式
# print(data1 * data2)

# 3. 张量的乘法运算
data1 = torch.tensor([[1, 2], [3, 4], [5, 6]])
data2 = torch.tensor([[5, 6], [7, 8]])
# 方式一
data3 = data1 @ data2
print(data3)
# 方式二
data4 = torch.matmul(data1, data2)
print(data4)